package com.example.demo_mysql_mybatisplus.util.easyexcel.exports.simple_export.dto;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 *
 **/
@Data
public class ExportConfig implements Serializable {
    private static final long serialVersionUID = 1L;

    private String module;
    private String fileName;
    private String fieldOfDataResult;// 结果集所在的字段位置
    int sheetSize = 5000;// 每个sheet页数据量

    private PageConfig pageConfig = new PageConfig();// 分页相关信息

    private List<ExcelHead> headList;// 导出的字段顺序和标题行配置
    private Map<String, Map<String, String>> valueMatchRules;// 数值映射规则，如 1=男，2=女
    private Map<String, String[]> valueConcatRules;// 数值拼接规则，如str1为str2+str3拼接的结果
    private Map<String, String> dateFormats;// 日期格式化规则


    public static boolean loseParam(ExportConfig a) {
        return a == null
                || CollUtil.isEmpty(a.getHeadList())
                ;
    }

    public static List<List<String>> convertHead(List<ExcelHead> headList) {
        List<List<String>> list = new ArrayList<>();
        for (ExcelHead head : headList) {
            list.add(Arrays.asList(head.getTitle()));
        }
        return list;
    }
}
